<!--  -->
<template>
  <div>
    <el-dialog title="添加底部容器操作" :visible.sync="dialogFormVisible">
      <el-form :model="form" @submit.native.prevent>
        <el-form-item label="选择栅格类型" :label-width="formLabelWidth" style="margin-bottom: 0px;">
          <el-radio-group v-model="form.girdtype" class="radio-disblock">
            <el-radio size="mini" label="col-sm">768px及以下（手机竖屏）换行</el-radio>
            <el-radio size="mini" label="col-md">992px及以下（手机横屏）换行</el-radio>
            <el-radio size="mini" label="col-lg">1200px及以下（ipad）换行</el-radio>
            <el-radio size="mini" label="col-xs">不换行</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="列数" :label-width="formLabelWidth" style="margin-bottom: 0px;">
          <el-input size="mini" type="number" style="width:80px;" v-model="form.col" min="1" max="24" placeholder="">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="dialogFormVisible = false">取 消</el-button>
        <el-button size="mini" type="primary" @click="submit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as WindowType from '@/config/windowtype.js'
import * as PubsubType from '@/config/pubsubtype.js'
import VueFunctions from '@/core/VueFunctions.js'
import { mapState } from 'vuex'
import PubSub from 'pubsub-js'
export default {
  created () {
    VueFunctions.method(WindowType.ADD_CONTAINER_FOOTERBOX, (obj) => {
      this.show()
    })
  },
  mounted () {
    PubSub.subscribe(PubsubType.PUBSUB_DIGLOG_COMPONENT_AND_CONTAINER_CLOSE, (event, data) => {
      this.close()
    })
  },
  computed: {
    ...mapState([
      'design'
    ])
  },
  data () {
    return {
      dialogFormVisible: false,
      form: {
        girdtype: 'col-sm',
        col: 1
      },
      formLabelWidth: '120px',
      // 点击确定下的回调函数，一般都是开启编辑弹窗赋值方法函数变量
      backSuccess: null
    }
  },
  methods: {
    close () {
      this.dialogFormVisible = false
      if (this.backSuccess && typeof this.backSuccess === 'function') {
        this.backSuccess()
        this.backSuccess = null
      }
    },
    show () {
      this.dialogFormVisible = true
    },
    submit () {
      // 点击确定后通过 this.form 制作出一套完成的容器数据json
      this.design.ref.contentWindow.vueFunc.addContainerFooterBox(this.form.col, this.form.girdtype)
      this.close()
    }
  }
}

</script>
<style scoped lang="scss">
.radio-disblock {
  padding-top: 5px;
  padding-bottom: 10px;

  /deep/ .el-radio {
    line-height: 30px;
    min-width: 40%;
  }
}
</style>
